// HSS.Forms.DateRangeSelector.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       DateRangeSelector.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace HSS.Forms
{
	/// <summary>
	/// A Date Range Selector
	/// </summary>
	public partial class DateRangeSelector : Form
	{
		/// <summary>
		/// Constructor
		/// </summary>
		public DateRangeSelector()
		{
			InitializeComponent();
		}

		/// <summary>
		/// The Begin Date
		/// </summary>
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Browsable(false)]
		public DateTime BeginDate
		{
			get { return _beginDate; }
			set
			{
				_beginDate = value;
				this.dtpBeginDay.Value = value;
				this.dtpBeginTime.Value = value;
			}
		} DateTime _beginDate;

		/// <summary>
		/// The End Date
		/// </summary>
		[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		[Browsable(false)]
		public DateTime EndDate
		{
			get { return _endDate; }
			set
			{
				_endDate = value;
				this.dtpEndDay.Value = value;
				this.dtpEndTime.Value = value;
			}
		} DateTime _endDate;

		private void btnCancel_Click(object sender, EventArgs e)
		{
			this.DialogResult = DialogResult.Cancel;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			_beginDate = new DateTime(
				this.dtpBeginDay.Value.Year
				, this.dtpBeginDay.Value.Month
				, this.dtpBeginDay.Value.Day
				, this.dtpBeginTime.Value.Hour
				, this.dtpBeginTime.Value.Minute
				, this.dtpBeginTime.Value.Second
				, DateTimeKind.Local);

			_endDate = new DateTime(
				this.dtpEndDay.Value.Year
				, this.dtpEndDay.Value.Month
				, this.dtpEndDay.Value.Day
				, this.dtpEndTime.Value.Hour
				, this.dtpEndTime.Value.Minute
				, this.dtpEndTime.Value.Second
				, DateTimeKind.Local);

			this.DialogResult = DialogResult.OK;
		}
	}
}